<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" id="d1">
<input type="button" value="帅哥" onclick="f(1)">
<input type="button" value="美女" onclick="f(2)">
<hr>
<script>
    let i=document.querySelector("#d1");
    function f(x) {

             for (let count=0; count<i.value;count++) {
                 let url = x == 1 ? "a.jpg" : "b.jpg";
                 let img = document.createElement("img");
                 img.src = url;
                 document.body.append(img);
             }
    }

</script>
</body>
</html>